<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="description" content="">
    <meta http-equiv="x-dns-prefetch-control" content="on">

    <title>提现</title>
    <link href="../../css/css.css" rel="stylesheet" type="text/css">
    <script src="../../js/jquery-v1.11.2.min.js"></script>
    <script src="../../js/driver.js"></script>
    <script src="../../js/common.js"></script>
</head>
<body>
<section class="subtitle mt10 p15">银行信息</section>
<form id="drawForm" method="post">

    <section class="itemgroup mt10 p15">
        <div class="oneitem">
            <font class="gray">开户银行</font>
            <font class="right tr" id="bankName"></font>
        </div>
        <div class="oneitem">
            <font class="gray">银行账号</font>
            <font class="right tr" id="accountNum"></font>
        </div>
        <div class="oneitem">
            <font class="gray">到账时间</font>
            <font class="right tr">每月20号之后提现金额到账</font>
        </div>
    </section>
    <section class="subtitle mt10 p15">提现信息</section>
    <section class="itemgroup p15">
        <div class="inputarea">
            <label class="inputnamebig">提现金额</label>
            <label class="inputformbig">
                <input class="formstyle w100" type="text" disabled="disabled" name="amount" id="amount"/>
            </label>
        </div>     
    </section>
    <section class="subtitle mt10 p15">提现规则</section>
    <section class="itemgroup p15"> 
        <label class="inputnamebig"></label>
            <label class="inputformbig">
                每月15号之前提成申请，金额为上个月客户通过微信或者支付宝支付的订单费用，15-20号进行审核，20号之后支付提现金额。
            </label>
    </section>
</form>
<section class="bottomarea">
    <button type="button" class="btn bottomonebtn" onclick="commitDraw()">提交</button>
</section>
<script type="text/javascript">
    $(function () {
        //token验证
        checkDriverToken();
    });
    var canUseMoney = 0;
    $(document).ready(function () {
        var url = _global.serverHost + "/capital/driver/withdrawalsView.htm";
        var data = {driverUuid: getCookie("driverUuid")};
        _callAjaxRequest(url, data, startBidBack);

        function startBidBack(data) {
            if (data.payAccount != null) {
                $("#accountNum").html(data.payAccount.accountNum);
                $("#bankName").html(data.payAccount.bankName);
            }
            $("#amount").attr("placeholder", data.canUseMoney);
            $("#amount").val(data.canUseMoney);
            canUseMoney = data.canUseMoney;
        }
    });

    function commitDraw() {
        if (canUseMoney == 0) {
            alert("您的提现金额为0");
            return false;
        }
        var amount = $("#amount").val();
        if (amount == null || amount == '' || isNaN(amount)) {
            alert("请输入本次提现金额");
            return false;
        }
        $.ajax({
            type: "POST",
            url: _global.serverHost + "/capital/driver/withdrawals.htm?driverUuid=" + getCookie("driverUuid"),
            data: {amount: canUseMoney},
            contentType: "application/x-www-form-urlencoded;charset=UTF-8",
            success: function (data) {
                alert(data.message);
                if (data.code == "1") {
                    window.location.href = "../../driver/wallet/index.html";
                }
                /* else if (data.code == "-1") {
                 window.location.href = "../../driver/login.html";
                 }*/
            }
        });
    }
</script>
</body>
</html>